Okay, So in this lecture, we're going to be taking a look at collision groups.
Now, collision groups allow us to manipulate how parts collide with other parts, meaning we can set
a part to be able to pass through one wall, but it won't be able to pass through another wall.
We can set the collision group of apart in studio using their collision group property, or we can do
it from scripts as well.
I have my neat little setup here to show you how collision groups work.
So we can go to the model tab and open up the Collision Group menu.
And here at the top we can hit this add group button.
And let's name our new group.
I'll just call this one ball.
And in here I can select which groups I want the ball group to collide or not collide with.
I'm going to create another group.
I'm going to call this one passable wall.
And I don't want the ball group to collide with the passable wall group.
So I'll uncheck this here, and I'm going to select the two parts that I want to be part of my ball
collision group, and then I can hit this plus button here.
And I have added these balls to the collision group.
You see it updated down here in the properties menu.
And for these walls down here, I just want the green one to be part of my passable wall collision group.
So I'll hit the plus button here.
The collision group property got updated.
And now this means that these two balls, one of these will hit this wall and not go through.
But this one right here will go straight through this wall.
So to show this, I'll run my game.
And there we go.
This one got stopped by this wall, but this one kept going straight through.
And we can also change how these balls interact with each other.
So back in my Collision group menu, I can actually disable the collisions with each other.
So that means if any of these two balls were to end up meeting each other, they would go straight through
each other.
As an example, I'll just duplicate this one and place it slightly below it in front of it.
And then if I run my game again.
You see, they pass right through each other.
And I can also update coalition groups from scripts as well.
So if I go into the server script service, I'm going to add a new script in here.
And from the script, I'm going to access something called the Physics Service, and I'll store it in
a variable.
His ex service.
And maybe I want to change the collision group of all the parts that make up a character of a player
in my game.
So I'll just do game players, Dot player added.
Connect a function to this, get the player and then when the player gets a character added to them,
we'll connect another function to that event, get a character, and then we're going to loop through
every single part.
And the character.
And if it is a.
Base part.
Then what we can do is we can get the parts collision.
Group property and we'll set it to.
Maybe we'll set it to the ball collision group.
Why not?
And from the script, I can use the physics service to access functions like Collision Group, set,
Collide table, or check if two collision groups are collectable or rename a collision group.
So if I do this function here, I'll pass the name of like passable wall and then I'll pass the name
of the default collision group.
And these two collision groups all set to false meaning they will no longer collide with each other.
So now if I go to play, test my game.
I spawn in my character.
Should be part of the ball collision group.
That's a little strange.
It's not updated here.
Well, I can tell I'm part of the ball collision group because I'm able to pass straight through the
slot.
Looks like it's just.
Has it been updated here in this collision group property?
But that's fine.
I am totally able to pass right through this wall and because in the script I have made passable walls
and the default collision group non collided with each other.
That means if I ran my game.
And then I were to.
Access this part right here that for some reason I can't access.
If I were to un anchor it, it should fall straight through the map.
Yep.
There we go.
So that's all about coalition groups.